package Demo1.operation;

import Demo1.Book.Book;
import Demo1.Book.Booklist;

import java.util.Scanner;

public class FindOperation implements IOperation{

    @Override
    public void work(Booklist booklist) {
        System.out.println("查找图书");
        System.out.println("请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = booklist.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBooks(i);
            if (book.getName().equals(name)){
                System.out.println("找到了你要查找的书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("你好像没有这本书");
    }
    }
}
